package com.adcc.loadsheet.monitor.util;

import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

/**
 * 时间工具类
 */
public class DateTimeUtil {

    public static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");

    /**
     * 获取当前的UTC时间
     *
     * @return
     */
    public static String getNowUTCTimeStr() {
        return DateTime.now(DateTimeZone.UTC).toString(DATE_TIME_FORMATTER);
    }

    /**
     * 获取减少小时候的日期
     * @param hours
     * @return
     */
    public static String getMinusHours(int hours){
        DateTime dateTime = DateTime.now(DateTimeZone.UTC).minusHours(hours);
        return dateTime.toString(DATE_TIME_FORMATTER);

    }

}
